package com.tbit.uqbike.object.pojo.dto;

import com.tbit.uqbike.manager.exception.BaseException;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;

/**
 * @author yee_
 * @version 1.0
 * @date 2023/3/13 21:52
 */
@Getter
@Setter
@ToString
public class PackageDelayDTO {
    /**
     * 优惠券:couponUserId
     * 骑行卡/会员卡  orderNO
     */
    private String busId;
    /**
     * 用户id
     */
    @NotNull(message = "请选择用户")
    private Integer userId;
    /**
     * 到期时间-时间戳
     */
    @NotNull(message = "请选择到期时间")
    private Long delayTime;
    /**
     * 操作密钥
     */
    private String pwd;

    public void valid(String type) {
        if (StringUtils.isBlank(busId)) {
            throw new BaseException("请选择需要延长的" + type);
        }
        if (System.currentTimeMillis() > delayTime) {
            throw new BaseException("到期时间不能在当前时间之前");
        }
    }

}
